package com.ruoyi.project.device.agvRest.controller;

import java.util.List;

import com.ruoyi.project.device.agvRest.domain.BasAgvRest;
import com.ruoyi.project.device.agvRest.service.IBasAgvRestService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AGV休息区管理Controller
 * 
 * @author ruoyi
 * @date 2023-08-22
 */
@Controller
@RequestMapping("/device/agvRest")
public class BasAgvRestController extends BaseController
{
    private String prefix = "device/agvRest";

    @Autowired
    private IBasAgvRestService basAgvRestService;

    @GetMapping()
    public String agvRest()
    {
        return prefix + "/agvRest";
    }

    /**
     * 查询AGV休息区管理列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasAgvRest basAgvRest)
    {
        startPage();
        List<BasAgvRest> list = basAgvRestService.selectBasAgvRestList(basAgvRest);
        return getDataTable(list);
    }

    /**
     * 导出AGV休息区管理列表
     */
    @Log(title = "AGV休息区管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasAgvRest basAgvRest)
    {
        List<BasAgvRest> list = basAgvRestService.selectBasAgvRestList(basAgvRest);
        ExcelUtil<BasAgvRest> util = new ExcelUtil<BasAgvRest>(BasAgvRest.class);
        return util.exportExcel(list, "AGV休息区管理数据");
    }

    /**
     * 新增AGV休息区管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AGV休息区管理
     */
    @Log(title = "AGV休息区管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasAgvRest basAgvRest)
    {
        return toAjax(basAgvRestService.insertBasAgvRest(basAgvRest));
    }

    /**
     * 修改AGV休息区管理
     */
    @GetMapping("/edit/{restAreaId}")
    public String edit(@PathVariable("restAreaId") Long restAreaId, ModelMap mmap)
    {
        BasAgvRest basAgvRest = basAgvRestService.selectBasAgvRestByRestAreaId(restAreaId);
        mmap.put("basAgvRest", basAgvRest);
        return prefix + "/edit";
    }

    /**
     * 修改保存AGV休息区管理
     */
    @Log(title = "AGV休息区管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasAgvRest basAgvRest)
    {
        return toAjax(basAgvRestService.updateBasAgvRest(basAgvRest));
    }

    /**
     * 删除AGV休息区管理
     */
    @Log(title = "AGV休息区管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basAgvRestService.deleteBasAgvRestByRestAreaIds(ids));
    }
}
